package com.ruoyi.system.domain;

import com.ruoyi.common.utils.ServletUtils;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 告警配置对象 sys_alarm_config
 * 
 * @author ruoyi
 * @date 2024-08-13
 */
@Data
public class SysAlarmConfig extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 告警配置id */
    private Long alarmConfigId;

    /** 告警名称 */
    @Excel(name = "告警名称")
    private String alarmName;

    /** 部门id */
    @Excel(name = "部门id")
    private Long deptId;

    /** 设备类型 1=热表 2=智能阀 3=温控阀 */
    @Excel(name = "设备类型 1=热表 2=智能阀 3=温控阀")
    private String deviceType;


    /** 告警内容 */
    @Excel(name = "告警内容")
    private String alarmContent;

    /** 告警级别 1=一级 2=二级 3=三级 */
    @Excel(name = "告警级别 1=一级 2=二级 3=三级")
    private String alarmLevel;

    /** 告警表达式 */
    @Excel(name = "告警表达式")
    private String alarmExpression;

    public String getAlarmExpression() {

        String result = alarmExpression;
        if (result == null){
            return result;
        }
        return ServletUtils.urlDecode(result);
    }

    private String regexReplace(final Pattern regex_pattern, final String replacement, final String s)
    {
        Matcher m = regex_pattern.matcher(s);
        return m.replaceAll(replacement);
    }

    /** 注入字段 */
    @Excel(name = "注入字段")
    private String injectionField;

    private List<Long> deviceIds;

    private List<SysDevice> deviceList;
    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
            .append("alarmConfigId", getAlarmConfigId())
            .append("alarmName", getAlarmName())
            .append("deptId", getDeptId())
            .append("deviceType", getDeviceType())
            .append("alarmContent", getAlarmContent())
            .append("alarmLevel", getAlarmLevel())
            .append("alarmExpression", getAlarmExpression())
            .append("injectionField", getInjectionField())
            .append("createTime", getCreateTime())
            .append("createBy", getCreateBy())
            .append("updateTime", getUpdateTime())
            .append("updateBy", getUpdateBy())
            .append("remark", getRemark())
            .toString();
    }
}
